package pers.cocoadel.springcloud.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import pers.cocoadel.springcloud.service.MsgProviderService;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author ZhenWuWang
 */
@EnableBinding(Source.class)
@Slf4j
public class MsgProviderServiceImpl implements MsgProviderService
{
    @Resource(name = "output")
    private MessageChannel outPut;

    @Override
    public String send()
    {
        String uuid = UUID.randomUUID().toString();
        outPut.send(MessageBuilder.withPayload(uuid).build());
        log.info("发送成功:" + uuid);
        return null;
    }
}
